home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 5
/
Gold Medal Software - Volume 5 (Gold Medal) (1995).iso
/
windows
/
win31
/
cenviw.arj
/
CMMGROUP.CMM
< prev
next >
Wrap
Text File
|
1994-03-08
|
4KB
|
105 lines
// CmmGroup.cmm - CEnvi sample file to demonstrate using DDE.lib,
// ver.1 DDEcli.lib and Progman.lib to create and fill a group
#include <ProgMan.lib>
#include <MsgBox.lib>
GroupName = "CEnvi Samples";
main(argc,argv)
{
CmmPath = GetFilePath(argv[0]);
sprintf(msg,"CmmGroup will create a Program Manager group\n"
"called \"%s\" containing all of the\n"
"*.cmm files in directory:\n"
" %s\n\nCreate Group?",GroupName,CmmPath);
if ( IDYES == MessageBox(msg,"Create CEnvi Samples Group?",MB_YESNO) ) {
// check if program manager is already running. If not then start it
if ( SpawnProgman = !IsProgmanRunning() ) {
// program manager is not executing, and so start it
if ( 0 == spawn(P_NOWAIT,"Progman.exe") ) {
ErrorMessage("Program Manager could not be started.");
exit(EXIT_FAILURE);
}
}
// connect to program manager and continue
ConnectToProgman();
AddCEnviGroup(CmmPath);
// work is done, so disconnect
CloseProgmanConnection();
// If program manager was manually started, then tell it to close
if ( SpawnProgman )
printf("ExitProgman returns %d\n",ExitProgman(True)),getch();
}
return(EXIT_SUCCESS);
}
AddCEnviGroup(path) // add group with all the .cmm files in this path
{
// determine that group does not already exist
if ( ProgmanGroupItems(GroupName,GInfo) ) {
ErrorMessage("Group \"%s\" already exists.\nCannot create group.",GroupName);
return;
}
// convert path to a full path name, with *.cmm file extension for the search
sprintf(SearchSpec,"%s\\*.cmm",FullPath(path));
// search the path directory for all *.cmm files
if ( !(FileList = Directory(SearchSpec)) ) {
ErrorMessage("No *.CMM files found");
return;
}
// create the CEnvi group and make sure it is active
assert( CreateGroup(GroupName) );
assert( ShowGroup(GroupName,PMG_SHOWACTIVE) );
// want full spec for the path
strcpy(FullPathSpec,SplitFileName(SearchSpec).dir);
// For the icon, will use CEnvi's icon, so need full path of CEnvi
CEnviFullSpec = GetMyExeSpec();
// for each file in FileList, add an entry in the group
for ( i = 0; i <= GetArraySpan(FileList); i++ ) {
filespec = FileList[i].name;
// Title will be name without the extension, first letter uppercase then all lower
strcpy(Title,SplitFileName(filespec).name);
strlwr(Title);
Title[0] = toupper(Title[0]);
AddItem(filespec,Title, // .CMM is associated, and so just add that file
CEnviFullSpec,0, // use the CEnvi.exe icon
-1,-1, // accept default position
FullPathSpec); // default directory
}
}
GetFilePath(PartialSpec) // return full directory path for this spec, without final '\'
{
dir = SplitFileName(FullPath(PartialSpec)).dir;
dir[strlen(dir)-1] = 0;
return dir;
}
GetMyExeSpec() // return full path for current CEnvi instance
{
ExeName[0] = ExeName[400] = '\0';
DynamicLink("KERNEL","GETMODULEFILENAME",SWORD16,PASCAL,
Instance(),ExeName,399);
return ExeName;
}
ErrorMessage(FormatString/*,arg,arg,arg*/) // display printf-like error message
{
va_start(va_list,FormatString);
vsprintf(msg,FormatString,va_list);
MessageBox(msg,"ERROR!",MB_ICONEXCLAMATION);
va_end(va_list);
}